package edu.gdpu.mybatis.mapper;

import edu.gdpu.mybatis.pojo.Dept;
import edu.gdpu.mybatis.pojo.Emp;
import edu.gdpu.mybatis.pojo.User;
import edu.gdpu.mybatis.utils.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class MyBatisTest02 {
    @Test
    public void check(){
        SqlSession sqlsession = SqlSessionUtil.getSqlsession();
        EmpMapper mapper = sqlsession.getMapper(EmpMapper.class);
        Emp empById = mapper.getEmpById(2);
        System.out.println(empById);
//        Emp empById2 = mapper.getEmpById2(3);
//        System.out.println(empById2);
    }

    @Test
    public void getEmpWithDeptById(){
        SqlSession sqlsession = SqlSessionUtil.getSqlsession();
        EmpMapper mapper = sqlsession.getMapper(EmpMapper.class);
        Emp empWithDeptById = mapper.getEmpWithDeptById(3);
        System.out.println(empWithDeptById);
    }

    @Test
    public void getEmpWithDeptById2(){
        SqlSession sqlsession = SqlSessionUtil.getSqlsession();
        EmpMapper mapper = sqlsession.getMapper(EmpMapper.class);
        Emp empWithDeptById2 = mapper.getEmpWithDeptById2(1);
        System.out.println(empWithDeptById2);
    }

    @Test
    public void getEmpWithDeptSetps(){
        SqlSession sqlsession = SqlSessionUtil.getSqlsession();
        EmpMapper mapper = sqlsession.getMapper(EmpMapper.class);
        Emp empWithDeptSetps = mapper.getEmpWithDeptSetps1(4);
        System.out.println(empWithDeptSetps);
    }
    @Test
    public void getEmpWithDeptSetps2(){
        SqlSession sqlsession = SqlSessionUtil.getSqlsession();
        DeptMapper mapper = sqlsession.getMapper(DeptMapper.class);
        Dept empWithDeptSetps = mapper.getEmpWithDeptSetps2(2);
        System.out.println(empWithDeptSetps);
    }

    @Test
    public void getDeptWithEmps(){
        SqlSession sqlsession = SqlSessionUtil.getSqlsession();
        DeptMapper mapper = sqlsession.getMapper(DeptMapper.class);
        Dept deptWithEmps = mapper.getDeptWithEmps(2);
        System.out.println(deptWithEmps);
    }
    @Test
    public void getDeptWithEmps2(){
        SqlSession sqlsession = SqlSessionUtil.getSqlsession();
        DeptMapper mapper = sqlsession.getMapper(DeptMapper.class);
        Dept deptWithEmpsBySteps = mapper.getDeptWithEmpsBySteps(2);
        System.out.println(deptWithEmpsBySteps);
    }
}
